package com.gsdse.controller;


import com.gsdse.pojo.ReturnData;
import com.gsdse.utils.SendEmailUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.net.HttpURLConnection;

/**
 *
 */
@Slf4j
@RestController
public class SendEmailController {

    @PostMapping("/sendExchangeDutyEmail")
    public ReturnData sendExchangeDutyEmail(@RequestParam("toUser") String toUser,
                                            @RequestParam("a") String a,
                                            @RequestParam("title") String title) throws Exception {

        SendEmailUtil.sendExchangeDutyEmail(toUser,a,title);
        ReturnData returnData = new ReturnData();
        returnData.setCode(0);
        returnData.setData(HttpURLConnection.HTTP_OK);
        returnData.setMsg("发送成功");
        return returnData;

    }

    @PostMapping("/sendPicEmail")
    public ReturnData sendPicEmail(@RequestParam("toUser") String toUser,
                                   @RequestParam("a") String a,
                                   @RequestParam("title") String title,
                                   @RequestParam("departmentId") String departmentId) throws Exception {
        SendEmailUtil.sendPicEmail(toUser,title,a,departmentId);
        ReturnData returnData = new ReturnData();
        returnData.setCode(0);
        returnData.setData(HttpURLConnection.HTTP_OK);
        returnData.setMsg("发送成功");
        return returnData;
    }





}